package com.example.gallerytab;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TabWidget;
import android.widget.TextView;

public class M_Tab extends TabActivity {
	private TabHost mTabHost;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.main);
		
		mTabHost = getTabHost();  
		LinearLayout ll = (LinearLayout)mTabHost.getChildAt(0);  
		TabWidget tw = (TabWidget)ll.getChildAt(0); 
		
		RelativeLayout tabIndicator1 = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.tab_indicator, tw, false);  
		TextView tvTab1 = (TextView)tabIndicator1.getChildAt(1);  
		tvTab1.setText("选项卡一");  
		TabSpec mTabSpc1 = mTabHost.newTabSpec("TAB_1")  
		        .setIndicator(tabIndicator1)  
		        .setContent(new Intent(this, Tab.class));
		
		RelativeLayout tabIndicator2 = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.tab_indicator, tw, false);  
		TextView tvTab2 = (TextView)tabIndicator2.getChildAt(1);  
		tvTab2.setText("选项卡二");  
		TabSpec mTabSpc2 = mTabHost.newTabSpec("TAB_2")  
		        .setIndicator(tabIndicator2)  
		        .setContent(new Intent(this, Tab.class));
		
		RelativeLayout tabIndicator3 = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.tab_indicator, tw, false);  
		TextView tvTab3 = (TextView)tabIndicator3.getChildAt(1);  
		tvTab3.setText("选项卡三");  
		TabSpec mTabSpc3 = mTabHost.newTabSpec("TAB_3")  
		        .setIndicator(tabIndicator3)  
		        .setContent(new Intent(this, Tab.class));
		
		mTabHost.addTab(mTabSpc1);
		mTabHost.addTab(mTabSpc2);
		mTabHost.addTab(mTabSpc3);
	}
}
